package com.qf.course.core.service.impl;

import com.qf.course.core.dao.CourseApplyDao;
import com.qf.course.core.entity.CourseApply;
import com.qf.course.core.service.CourseApplyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 课程申请表(CourseApply)表服务实现类
 *
 * @author makejava
 * @since 2022-08-04 10:43:34
 */
@Service
public class CourseApplyServiceImpl implements CourseApplyService {
    @Resource
    private CourseApplyDao courseApplyDao;

    /**
     * 通过ID查询单条数据
     *
     * @param sid 主键
     * @return 实例对象
     */
    @Override
    public CourseApply queryById(Integer sid) {
        return this.courseApplyDao.queryById(sid);
    }


    /**
     * 新增数据
     *
     * @param courseApply 实例对象
     * @return 实例对象
     */
    @Override
    public CourseApply insert(CourseApply courseApply) {
        this.courseApplyDao.insert(courseApply);
        return courseApply;
    }

    /**
     * 修改数据
     *
     * @param courseApply 实例对象
     * @return 实例对象
     */
    @Override
    public CourseApply update(CourseApply courseApply) {
        this.courseApplyDao.update(courseApply);
        return this.queryById(courseApply.getSid());
    }

    /**
     * 通过主键删除数据
     *
     * @param sid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer sid, Integer cid) {
        return this.courseApplyDao.deleteById(sid, cid) > 0;
    }
}
